package com.leetcode.algorithm.y22.m06;

import java.util.Arrays;

/**
 * 976. 三角形的最大周长
 * 
 * https://leetcode.cn/problems/largest-perimeter-triangle/
 * 
 * @author jie.deng
 *
 */
class Question0976Solution01 {
	
	public int largestPerimeter(int[] nums) {
		Arrays.sort(nums);
		for (int i = nums.length - 1; i >= 2; i--) {
			if (nums[i] < nums[i - 1] + nums[i - 2]) {
				return nums[i] + nums[i - 1] + nums[i - 2];
			}
		}
		return 0;
	}
    
}